<?php
header('Access-Control-Allow-Origin:*');
set_time_limit(300);
defined('IN_CMS') or exit('No permission resources.');
//模型缓存路径
define('CACHE_MODEL_PATH',CACHE_PATH.'caches_model'.DIRECTORY_SEPARATOR.'caches_data'.DIRECTORY_SEPARATOR);
//定义在单独操作内容的时候，同时更新相关栏目页面
define('RELATION_HTML',true);

pc_base::load_app_class('admin','admin',0);
pc_base::load_sys_class('form','',0);
pc_base::load_app_func('util');
pc_base::load_sys_class('format','',0);
pc_base::load_app_func('global');

$db = pc_base::load_model('content_model');
/*include_once "../cms/model/content_model.class.php";
$db = new content_model();*/
$db->set_model(1);
$order =    "id desc";
$page = 1;
$pagesize = $_REQUEST['limit'] ?? 14;
$catid = $_REQUEST['catid'] ?? 6;
if($catid){
    $where  =   "(b.catid=$catid or b.parentid=$catid or arrparentid like '%,$catid%') and a.status=99";
}else{
    $where  =   "a.status=99";
}
$sql = "select a.*,b.catname,c.filepath from dgg_news  a 
        left join  dgg_category b on a.catid=b.catid
        left join  dgg_attachment c on a.thumb=c.aid
        where ".$where." order by a.id desc  limit 0,14";
$data = $db->query($sql);
// uploadfile/2024/0328/28a02eb5abdd404.png
$home = siteurl(1, $mobile = 0);
while ($i = mysqli_fetch_array($data, MYSQLI_ASSOC)){
    $i['filepath'] = $i['filepath']?$home."/uploadfile/".$i['filepath']:'';
    $datas[] = $i;
}
//$datas = $db->select($where,'*',$pagesize,$order);
dr_json(200,'success',$datas);
exit;;


?>